<?php if (!defined('LEGAL_INNER_USE')){die('ILLEGAL USING!');}?>
<?php
#http://127.0.0.1:8008/holishanghai/index.php?k=nokia&main_page=searchResult
$keywords = trim(isset($_GET['k'])?$_GET['k']:'');
$keywords = str_replace("'", '', $keywords);

if (!empty($keywords)){
	$per_page = 20;
	$page = isset($_GET['page'])?$_GET['page']*1:1;
	$page = ($page<1)?1:$page;
	
	$breadcrumb = '';
	
	#产品信息
	$sql = "SELECT COUNT(*) AS t FROM ".DB_PRE.DB_PRE_ECSHOP."goods WHERE (goods_name LIKE '%$keywords%' OR goods_sn='$keywords' OR keywords LIKE '%$keywords%') AND is_on_sale=1";
	#计数
	$totals = $db -> execute($sql) -> fields['t'];
	$total_pages = ceil($totals/$per_page);
	$page = ($page>$total_pages)?$total_pages:$page;
	$page = ($page<1)?1:$page;
	
	$sql = "SELECT goods_id, goods_name, shop_price, goods_thumb, cat_id FROM ".DB_PRE.DB_PRE_ECSHOP."goods WHERE (goods_name LIKE '%$keywords%' OR goods_sn='$keywords' OR keywords LIKE '%$keywords%') ORDER BY sort_order DESC, goods_id DESC LIMIT ".(($page-1)*$per_page).", $per_page";
	
	$goods = diy_execute($sql);
	for ($i=0; $i<(sizeof($goods))%4; $i++){
		$goods[] = false;
	}
} else {
	$goods = false;
}